import { defineUserConfig, defaultTheme } from 'vuepress'
import { activeHeaderLinksPlugin } from '@vuepress/plugin-active-header-links'
import { searchPlugin } from '@vuepress/plugin-search'
import { mediumZoomPlugin } from '@vuepress/plugin-medium-zoom'
// import { docsearchPlugin } from '@vuepress/plugin-docsearch'

export default defineUserConfig({
  plugins: [
    activeHeaderLinksPlugin({
      // 配置项
      headerLinkSelector: 'a.sidebar-link',
      headerAnchorSelector: '.header-anchor'
    }),
    // docsearchPlugin({
    // }),
    searchPlugin({
      // 配置项
    }),
    mediumZoomPlugin({
      // 配置项
    }),
  ],
  lang: 'zh-CN',
  title: '前端小白的杂录',
  base: '/personalblog/',
  dest: './dist',
  port: 5050,
  head: [
    // 设置 favor.ico，.vuepress/public 下
    ['link',{rel: 'icon',href: '/personalblog/assets/img/logo.png'}]
  ],
  theme: defaultTheme({
    // 默认主题配置
    navbar: [
      { text: '首页', link: '/' },
      {
        text: '前端知识库',
        children: [
          { text: 'React框架', link: '/Frontend/React/' },
          { text: 'TypeScript', link: '/Frontend/Typescript/' },
          { text: '正则表达式', link: '/Frontend/Regular/' },
          { text: 'Canvas', link: '/Frontend/Canvas/' },
        ]
      },
      { text: '必应', link: 'https://cn.bing.com/' },
    ],
    search: true, // 启用搜索框
    searchMaxSuggestions: 10, // 最大搜索结果数
    sidebarDepth: 2,
    logo: '/assets/img/logo.png',
    sidebar: {
      '/Frontend/React/': [
        {
          text: 'React',
          collapsible: false,
          children: [
            'README.md',
            'a.md'
          ]
        }
      ],
      '/Frontend/Typescript/': [
        {
          text: 'TypeScript基础',
          collapsible: true,
          children: [
            'README.md',  // 简介
            'Primer.md',  // TypeScript入门
            'CommonlyUsedType.md',  // 常用类型
            'TypeShrink.md',  // 类型缩小
            'Function.md',  // 函数类型
            'Object.md',  // 对象类型
            'TypeOperation.md',  // 类型操纵
            'Class.md',  // 类
            'Module.md',  // 模块
          ]
        },
        {
          text: 'TypeScript进阶',
          collapsible: true,
          children: [
            '1.md',
          ]
        },
      ],
      '/Frontend/Regular/': [
        {
          text: '正则表达式',
          collapsible: false,
          children: [
            'README.md',  // 基础知识
            'Metacharacter.md',  // 元子字符
            'ModeEmbellish.md',  // 模式修饰
            'AtomicTables.md',  // 原子表
            'AtomicGroup.md',  // 原子组
            'DuplicateMatching.md',  // 重复匹配
            'GlobalMatching.md',  // 全局匹配
            'StringFunction.md',  // 字符方法
            'RegExpFunction.md',  // 正则方法
            'AssertionMatching.md',  // 断言匹配
          ]
        }
      ],
      '/Frontend/Canvas/': [
        {
          text: 'Canvas',
          collapsible: false,
          children: [
            'README.md',  // 认识Canvas
            'BasicFigure.md',  // 绘制基本图形
          ]
        }
      ]
    },
  })
})